package com.ws.mbp.springsecuritydemo.controller;

import com.ws.mbp.springsecuritydemo.utils.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@Tag(name = "其他接口", description = "其他接口")
public class SecurityOtherAction {

    @GetMapping("/other/add")
    public R add() {
        System.out.println("其他控制器认证成功即可。。。。。。。。。");
        return new R(200, "可以访问", null);
    }
    @PreAuthorize("hasRole('ADMIN')")
    @GetMapping("/temp/testadmin")
    public R t1() {
        System.out.println("admin访问。。。。。。。。。");
        return new R(200, "可以admin访问访问", null);
    }
    @PreAuthorize("hasRole('TEACHER')")
    @GetMapping("/temp/testteacher")
    public R t2() {
        System.out.println("testteacher。。。。。。。。。");
        return new R(200, "可以testteacher访问", null);
    }
    @PreAuthorize("hasRole('STUDENT')")
    @GetMapping("/temp/teststudent")
    public R t3() {
        System.out.println("teststudent。。。。。。。。。");
        return new R(200, "teststudent", null);
    }
    @PreAuthorize("hasAuthority('ROLE_STUDENT')")
    @GetMapping("/temp/teststudent2")
    public R t23() {
        System.out.println("teststudent2。。。。。。。。。");
        return new R(200, "teststudent2", null);
    }


}